package backpropagationv1;

public class Neurona {
    /*CONSTRUCTORES */
    public Neurona(int inputs){
        this.w = new float[inputs];
        this.f_act = new Funcion(1,0);
        init();
    }

    public Neurona(int inputs, Funcion _f_act){
        this.w = new float[inputs];
        this.f_act = _f_act;
        init();
    }

    /*METODOS*/
    private void init(){
        for(int i=0; i<w.length;i++){
            w[i] = (float)(Math.random() * 0.1);
        }
    }

    private float funcionActivacion(float s){
        return f_act.eval(s);
    }

    public float f(float[] x){
        float sumproduct = 0, output = 0;
        for(int i=0; i<w.length;i++){
            sumproduct = sumproduct + w[i]*x[i];
        }
        output = funcionActivacion(sumproduct);
        return output;
    }

    /*VARIABLES GLOBALES DE LA CLASE*/
    public float w[];
    private Funcion f_act;
}
